<template>
  <div class="aui-card-list">
    <el-card shadow="never" class="aui-card-list-body">
      <vxe-toolbar :setting="{immediate:true}">
        <template v-slot:buttons>
          <el-button v-if="$hasPermission('flowable:bpmAgent:save')" type="primary" @click="addOrUpdateHandle()">
            {{ $t('add') }}
          </el-button>
          <el-button v-if="$hasPermission('flowable:bpmAgent:delete')" type="danger" @click="deleteHandle()">
            {{ $t('deleteBatch') }}
          </el-button>
        </template>
        <template v-slot:tools>
          <el-button icon="el-icon-refresh" @click="getDataList()" circle></el-button>
          <!-- <el-button icon="el-icon-download" @click="$refs.xTable.openExport()" circle></el-button> -->
        </template>
      </vxe-toolbar>
      <div class="aui-card-list-body-table">
        <vxe-table :loading="dataListLoading" :data="dataList" ref="xTable" auto-resize class="vxe-table-element" remote-sort @sort-change="dataListSortChangeHandle" @select-change="dataListSelectionChangeHandleVex" @select-all="dataListSelectionAllChangeHandleVex" max-height="auto">
          <vxe-table-column type="checkbox" width="50" align="center"></vxe-table-column>
          <vxe-table-column field="procName" title="bpmAgent.procName">
          </vxe-table-column>
          <vxe-table-column field="agentRealName" title="bpmAgent.agentRealName">
          </vxe-table-column>
          <vxe-table-column field="startDate" title="bpmAgent.startDate" align="center">
            <template slot-scope="scope">
              {{$getDateStr(scope.row.startDate)}}
            </template>
          </vxe-table-column>
          <vxe-table-column field="endDate" title="bpmAgent.endDate" align="center">
            <template slot-scope="scope">
              {{$getDateStr(scope.row.endDate)}}
            </template>
          </vxe-table-column>
          <vxe-table-column field="status" title="bpmAgent.status" width="80">
            <template slot-scope="scope">
              <el-tag size="small" v-if="scope.row.status=='1'">开启</el-tag>
              <el-tag size="small" v-if="scope.row.status=='0'" type="danger">关闭</el-tag>
            </template>
          </vxe-table-column>
          <vxe-table-column field="remark" title="bpmAgent.remark">
          </vxe-table-column>
          <vxe-table-column title="handle" fixed="right" width="120" align="center">
            <template slot-scope="scope">
              <el-button v-if="$hasPermission('flowable:bpmAgent:update')" icon="el-icon-edit" type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">{{ $t('update') }}
              </el-button>
              <el-button v-if="$hasPermission('flowable:bpmAgent:delete')" type="text" icon="el-icon-delete" size="small" @click="deleteHandle(scope.row.id)">{{ $t('delete') }}
              </el-button>
            </template>
          </vxe-table-column>
        </vxe-table>
        <el-pagination :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit" :total="total" layout="total, sizes, prev, pager, next, jumper" @size-change="pageSizeChangeHandle" @current-change="pageCurrentChangeHandle">
        </el-pagination>
        <!-- 弹窗, 新增 / 修改 -->
        <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
      </div>
    </el-card>
  </div>
</template>
<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './bpmAgent-add-or-update'
export default {
  mixins: [mixinViewModule],
  data () {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/flowable/bpmAgent/page',
        getDataListIsPage: true,
        deleteURL: '/flowable/bpmAgent',
        deleteIsBatch: true,
        exportURL: '/flowable/bpmAgent/export'
      },
      dataForm: {
        id: ''
      }
    }
  },
  components: {
    AddOrUpdate
  }
}
</script>
